<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" src="<%=path %>/static/utf8-jsp/ueditor.all.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>

<SCRIPT type="text/javascript">
  $.ajaxSetup({
     async: false
  });
    <!--
    genDicJs(['008','012']);
    var formSetting = {
    		po:'QhTask',
    		title:"",
    		formid:"formedit",
    		hiddens:["id","adver","createUser","createDateTime","modifyUser","modifyDateTime","state"],
    	fields:[
    	     [
                {tdwidth:100,title:"计划名称",field:"计划名称",type:"text",name:"name",width:592,datatype:"Require",msg:"请输入计划名称！",colspan:3}
             ],
             [
                {title:"分享标题",field:"分享标题",type:"text",name:"title",width:592,datatype:"Require",msg:"请输入分享标题！",colspan:3}
             ],
             [
                {title:"投放日期",field:"投放日期",type:"text",name:"",width:758,datatype:"Require",msg:"请输入推广链接！",colspan:3}
             ],
             [
                {title:"投放时间",field:"投放时间",type:"text",name:"",width:758,datatype:"Require",msg:"请输入推广链接！",colspan:3}
             ],
             [
                {title:"推广链接",field:"推广链接",type:"text",name:"advLink",width:592,datatype:"Require",msg:"请输入推广链接！",colspan:3}
             ],
             [
                {title:"产品类型",field:"产品类型",dic:"012",type:"select",name:"type",width:378,datatype:"Require",msg:"请选择产品类型！",colspan:3}
             ],
             [
                {title:"每日预算",field:"每日预算",type:"text",name:"investAmount",width:374,datatype:"Money",msg:"请输入格式正确的每日预算！",colspan:3}
             ],
             [
                {title:"投放位置",field:"投放位置",type:"text",name:"",width:150,colspan:3}
             ],
             [
                {title:"广告规格",field:"广告规格",type:"uploadimg",name:"picUrl",width:260,colspan:3}
             ],
    		 [
                {title:"广告文案",field:"广告文案",type:"text",name:"advCopy",width:758,colspan:3}
             ],
             [
                {title:"付费模式",field:"付费模式",type:"text",name:"",width:150,colspan:3}
             ],
             [
                {title:"广告出价",field:"广告出价",type:"text",name:"advPrice",width:150,datatype:"Money",msg:"请输入格式正确的广告出价！",colspan:3}
             ],
             [
                {title:"显示最高收益",field:"显示最高收益",type:"text",name:"commission",width:150,datatype:"Money",msg:"单位为元，输入格式为1.5!"},
                {title:"实际最高收益",field:"实际最高收益",type:"text",name:"realCommission",width:150,datatype:"Money",msg:"单位为元，输入格式为1.3！"}
             ],
             [
                {title:"分享收益",field:"分享收益",type:"text",name:"shareProfit",width:150,datatype:"Money",msg:"单位为次/元，输入格式为0.06!"},
                {title:"阅读收益",field:"阅读收益",type:"text",name:"readProfit",width:150,datatype:"Money",msg:"单位为次/元，输入格式为0.03！"}
             ],
             [
                {title:"分享方向",field:"分享方向",type:"select",name:"shareDirect",width:154,dic:"008",datatype:"Require",msg:"请选择分享方向！"},
                {title:"排序",field:"排序",type:"int",name:"sort",width:150,datatype:"Number",msg:"请输入格式正确的排序！",colspan:3,value:0}
             ]

             ],
		toolbar:{align:'right',buttons:[
		     {
                  id:'return',
                  title:'返回',
                  cssclass:'btnyellow',
                  handlers:{
                       click: function(){
                            location.href="/qh/public/common/r2.htmls?page=task/task_list";
                       }
                  }
             },
		                 			  {
		                 			    	 id:'save',
		                 			    	 title:'提交',
		                 			    	 handlers:{
		                 			    		 click: function(){
		                 			    			 if(!Validator.Validate(document.getElementById('formedit'),0)){
		                 			    			    return;
		                 			    			 }
		                 			    			 form.save(function(ret) {
                                                         if (ret == -1) {
                                                             layer.alert("数据保存失败，请重试！");
                                                         } else {
                                                             $.getJSON(g_path+"/public/common/setShareUrl.htmls",{id:ret.id},function(data){
                                                                 if(data.state==1){
                                                                     layer.msg("数据已保存！");
                                                                     setTimeout("location.href='/qh/public/common/r2.htmls?page=task/task_list'",2000);
                                                                 }
                                                             });

                                                         }
                                                     });
		                 			    		 }
		                 			    	 }
		                 			  },
		                 			  {
                                          id:'audit',
                                          title:'审核',
                                          handlers:{
                                              click: function(){
                                                 audit();
                                              }
                                          }
                                      }
		     ]}
    }

	var form;
    $(document).ready(function(){
    	form = new FormView("formview",formSetting);
    	form.init();

    	var html1="<input field='开始日期' uitype=\"datetime\" type=\"text\" name=\"startDate\" datatype=\"Require\" msg=\"请选择开始日期！\" onclick=\"WdatePicker()\" />";
        html1+="<span style='margin:0 12px'>to</span><input field='结束日期' uitype=\"datetime\" type=\"text\" name=\"endDate\" datatype=\"Require\" msg=\"请选择结束日期！\" onclick=\"WdatePicker()\" />";
        $("tr[rowindex=3]").children().eq(1).html(html1);

        var html2="<input field='投放时间' onclick='selTime(1)' uiType='radio' type='radio' name='timeType' id='rdoTime1' value='全时间段' /><label for='rdoTime1'>全时间段</label><input field='投放时间' style='margin-left:24px;' onclick='selTime(2)' uiType='radio' type='radio' name='timeType' id='rdoTime2' value='特定时间段' /><label for='rdoTime2'>特定时间段</label><input field='开始时间' style='margin-left:26px;' uitype=\"datetime\" type=\"text\" name=\"startTime\" datatype=\"Require\" msg=\"请选择开始时间！\" onclick=\"WdatePicker({dateFmt:'HH:mm'})\" />";
        html2+="<span style='margin:0 12px'>to</span><input field='结束时间' uitype=\"datetime\" type=\"text\" name=\"endTime\" datatype=\"Require\" msg=\"请选择结束时间！\" onclick=\"WdatePicker({dateFmt:'HH:mm'})\" />";
        $("tr[rowindex=4]").children().eq(1).html(html2);

        var html3="<input field='投放位置' uiType='radio' type='radio' name='investPosition' id='rdoPosition1' value='信息流' /><label for='rdoPosition1'>信息流</label>";
        html3+="<input field='投放位置' style='margin-left:48px;' uiType='radio' type='radio' name='investPosition' id='rdoPosition2' value='焦点图' /><label for='rdoPosition2'>焦点图</label>";
        html3+="<input field='投放位置' style='margin-left:48px;' uiType='radio' type='radio' name='investPosition' id='rdoPosition3' value='开机大图' /><label for='rdoPosition3'>开机大图</label>";
        $("tr[rowindex=8]").children().eq(1).html(html3);

        var html4="<input field='付费模式' checked='checked' uiType='radio' type='radio' name='payMode' id='rdoPayMode1' value='分享' /><label for='rdoPayMode1'>分享（次）</label>";
        $("tr[rowindex=11]").children().eq(1).html(html4);
        $("tr[rowindex=12]").children().eq(1).append("<span style='margin-left:10px;'>元/分享（次）</span>")

    	var id='${param.id}';
    	if(id!=null&&id!=""){
    	   loadData(id);
    	}

    	/*$.getJSON(g_path+"/public/common/getQhSysPar.htmls",{},function(data){
    	   $("input[name=shareProfit]").val(data.shareProfit);
    	   $("input[name=readProfit]").val(data.readProfit);
    	});

    	$("input[name=shareProfit]").change(function(){
    	   $("input[name=shareProfit]").val($("input[name=shareProfit]").val());
    	});

    	$("input[name=readProfit]").change(function(){
            $("input[name=readProfit]").val($("input[name=readProfit]").val());
        });*/

		ajustHeight();
    });

    function loadData(id){
       form.loadData(id, "QhTask");
       if($("input[name=state]").val()=="1"){
          $("#audit").hide();
       }
    }

    var $$ = function(func){
        if (document.addEventListener) {
            window.addEventListener("load", func, false);
        }
        else if (document.attachEvent) {
            window.attachEvent("onload", func);
        }
    }
    $$(function(){

    });
    function selTime(id){
        if(id==1){
           $("input[name=startTime]").val("00:00");
           $("input[name=endTime]").val("23:59");
        }
        else{
           $("input[name=startTime]").val("");
           $("input[name=endTime]").val("");
        }
    }

    function audit(){
       $.getJSON(g_path+"/public/common/setCommission.htmls",{id:"${param.id}"},function(data){
          layer.alert("审核成功！");
          loadData("${param.id}");
       });
    }
    //-->
</SCRIPT>
</head>

<body>
<ul class=tab_nav>
  <li>
    <a href="/qh/public/common/r2.htmls?page=task/task_list">投放计划</a>
  </li>
  <li>
    <a class="current" href="">新建计划</a>
  </li>
</ul>
<div class="contrainer">
<div id="formview0" class="rbox1"></div>
<div id="formview" class="rbox1" style="margin-top:10px;"></div>
<div id="list" class="rbox2"></div>
<div id="fmUploadImg" style="display:none">
    <form method="post" enctype="multipart/form-data" name="form1" id="form1">
        <table>
            <tr>
                <td style="padding:20px 0 0 20px;">
                    <input type="file" name="userfile" id="inputImg" />
                </td>
            </tr>
        </table>
    </form>
</div>
</div>
<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>

</body>
</html>